package net.seehope.foodie.common;

public class JsonResult {

/**
 * 响应状态码，和前端约好，什么错误返回什么样的状态码
 * 200表示成功
 * 500表示异常
 * 
 */
	private Integer status;
	
/**
 * 错误提示，是有状态码失败的情况下才有用，
 * 告诉前端，响应错误的具体原因	
 */
	private String msg;
	
/**
* 数据区域，如果响应成功，那么接口数据放在data中
*/
	private Object data;

	
public JsonResult() {}	
	
public JsonResult(Integer status, String msg, Object data) {
	this.status = status;
	this.msg = msg;
	this.data = data;
}

public Integer getStatus() {
	return status;
}

public void setStatus(Integer status) {
	this.status = status;
}

public String getMsg() {
	return msg;
}

public void setMsg(String msg) {
	this.msg = msg;
}

public Object getData() {
	return data;
}

public void setData(Object data) {
	this.data = data;
}


/**
 * 响应成功的话，将数据返回
 * 
 */
	public static JsonResult isOk(Object data) {
		return new JsonResult(200,"ok",data);
	}
	
	
	public static JsonResult isOk1(Object data) {
		return new JsonResult(201,"ok",data);
	}
	
/**
 * 响应失败的话，返回错误信息	
 */
	
	public static JsonResult errorMsg(String msg) {
		return new JsonResult(500,msg,null);
	}
	
	public static JsonResult errorAuthorized(String msg) {
		return new JsonResult(401,msg,null);
	}
	
	
	
	
}
